<template>
	<view class="content">
		<view class="a">
		</view>
		<view v-if="orderList.length!=0" class="item" v-for="item in orderList" @click="toOrderDetail(item.id)">
			<view class="left">
				<image v-if="item.productSpecifications.slice(0,2)=='罩衣'"
					src="https://images.linglinggong.net/static/gongzhuang/6.png" mode="">
				</image>
				<image v-else src="https://images.linglinggong.net/static/gongzhuang/list-item.png" mode=""></image>
				<view class="detail">
					<view class="" v-if="item.productSpecifications.slice(0,2)=='罩衣'"> 找零工罩衣 </view>
					<view class="" v-else> 找零工春夏季短T </view>
					<view class="">
						<text v-if="item.productSpecifications.slice(0,2)=='罩衣'">罩衣</text>
						<text v-else>短袖两件</text>
						<text style="margin-left: 20rpx;">{{item.tradeName}}</text>
					</view>
					<view class="">
						<span>￥</span>{{item.commodityPrice*item.purchaseQuantity}}
					</view>
				</view>
			</view>
			<view class="right">
				<view :style="{color:item.status=='已发货'?'#A5A5A5':'#FF721D'}">
					{{item.status}}
				</view>
				<view> {{item.actualShipmentsNumber}}件 </view>
			</view>
		</view>
		<view class="empty" v-else>
			<image src="https://images.linglinggong.net/XCX/gongzhuang/order-empty.png" mode=""></image>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				orderList: [],
			};
		},
		onShow() {
			this.getOrderList()
		},
		methods: {
			async getOrderList() {
				let res = await this.$fetch(this.$api.ordering_information_list, {}, 'GET')
				if (res.code) return uni.showToast({
					title: res.msg,
					icon: 'none'
				})
				for (let i = 0; i < res.data.length; i++) {
					if (res.data[i].trackingNumber) {
						res.data[i].status = "已发货"
					} else {
						res.data[i].status = "待发货"
					}
				}
				this.orderList = res.data
				this.orderList.forEach((item) => {
					item.commodityPrice = item.commodityPrice.toFixed(2)
				})
			},
			toOrderDetail(id) {
				uni.navigateTo({
					url: `/pages/syncAppNewPage/buy-clothing/order-message/order-detail?id=${id}`
				})
			}
		}
	}
</script>
<style lang="less">
	.content {
		.a {
			height: 1rpx;
		}

		.empty {
			width: 414rpx;
			height: 370rpx;
			margin: 30vh auto;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.item {
			width: 690rpx;
			height: 240rpx;
			margin: 20rpx auto;
			background: #fff;
			border-radius: 20rpx;
			padding: 40rpx 20rpx;
			box-sizing: border-box;
			display: flex;
			justify-content: space-between;

			.left {
				display: flex;

				image {
					width: 160rpx;
					height: 160rpx;
					margin-right: 30rpx;
				}

				.detail {
					font-weight: bold;
					display: flex;
					flex-direction: column;
					justify-content: space-between;

					view:nth-child(1) {
						color: #262626;
						font-size: 32rpx;
					}

					view:nth-child(2) {
						color: #A5A5A5;
						font-size: 24rpx;
						margin-top: -20rpx;
					}

					view:nth-child(3) {
						color: #262626;
						font-size: 32rpx;

						span {
							font-size: 24rpx;
							font-weight: normal;
						}

						span:nth-child(1) {
							font-weight: bold;
						}
					}
				}
			}

			.right {
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				text-align: right;

				view:nth-child(1) {
					font-size: 24rpx;
				}

				view:nth-child(2) {
					font-size: 28rpx;
					color: #515151;
				}
			}
		}
	}
</style>